﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.Data;
using System.Windows.Controls;


namespace HA.ModFlow.Application
{

   public class GridFrameViewModel:MDTVIViewModel
    {

       public GridFrameViewModel(MDTVIViewModel parent)
           : base(parent, false)
       {
           //this._gridFrame = gf;


           this._contextMenu = new System.Windows.Controls.ContextMenu();
           MenuItem mi = new MenuItem();
           mi.Header = "缩放到...";
           mi.Command = GISCommands.ExtentToCurrent;
           mi.CommandParameter = GisModule.DefaultModule.GridFrameLayerId;

           this._contextMenu.Items.Add(mi);

           this._contextMenu.Items.Add(new Separator());



           mi = new MenuItem();
           mi.Header = "删除";
           mi.Command = DataCommands.RemoveGridFrame;

           this._contextMenu.Items.Add(mi);


           
           mi = new MenuItem();
           mi.Header = "适应到图层大小";
           mi.Command = DataCommands.GridFrameFitToCoverage;

           this._contextMenu.Items.Add(mi);


           mi = new MenuItem();
           mi.Header = "映射到";
           //子项
           MenuItem menu = new MenuItem();
           menu.Header = "三维网格";
           menu.Command = DataCommands.GridFrameMapToGrid3d;
         

           mi.Items.Add(menu);

           //menu = new MenuItem();
           //menu.Header = "3DGrid";
           //mi.Items.Add(menu);

           this._contextMenu.Items.Add(mi);


           Separator sep = new Separator();
           this._contextMenu.Items.Add(sep);


           MenuItem miProp = new MenuItem();

           miProp.Command = DataCommands.GridFrameProp;

           miProp.Header = "属性";

           this._contextMenu.Items.Add(miProp);

           this._imageSource = VMImageSource.Frame;


 
       }


       public override System.Windows.Input.ICommand DoubleClickCommand
       {
           get
           {
               return DataCommands.GridFrameProp;
           }
       }

       //GridFrame _gridFrame;

       //public GridFrame GridFrame
       //{
       //    get { return _gridFrame; }
       //    set { _gridFrame = value; }
       //}

       public override string Desc
       {
           get
           {
               return HAUtil.LanguageTranslater.ENToCN(ProjectService.DefaultService.Project.MapData.GridFrame.Name);
           }
       }


        #region 重写 的方法

       protected override void OnSelectedChanged()
       {
           if (this.IsSelected)
           {

               UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.MAPDATA;

               string name = GisModule.DefaultModule.GridFrameLayerId;

               GisModule.DefaultModule.SetCurrentLayer(name);

               GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(HAGISV2.MAPMODE.GRIDFRAME);


              

           }
       }


       protected override void OnCheckedChanged()
       {
           GisModule.DefaultModule.SetLayerVisible(GisModule.DefaultModule.GridFrameLayerId,this.IsChecked);
       }


        #endregion


    }
}
